package com.py.credit.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.SysUser;
import com.py.credit.service.LoseCreditService;
import com.py.credit.service.RemoteBaseService;
import com.py.framework.core.helper.HttpServletHelper;

/**
 * 异议处理controller
 */
@RestController
@RequestMapping(value = "/loseCredit")
public class LoseCreditController {
	
	private final static String FRONT_TABLE_ID = "loseCredit";

    @Autowired
    private LoseCreditService loseCreditService;

    @Autowired
    private RemoteBaseService remoteBaseService;

    @Value("${absolutepath}")
    private String absolutepath;

    
    /**
     * 异议修改分页列表
     * @return
     */
    @RequestMapping(value = "/initMessData.json")
    public RestServiceResult<List<Map>> initMessData(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<List<Map>> messData = remoteBaseService.getMessDatas();

        List<Map> listMap=messData.getData();

        if(null!=listMap && listMap.size()>0){
            loseCreditService.initMessData(listMap);
        }

        return result;
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/mianBodyRate.json")
    public RestServiceResult<Map> mianBodyRate(HttpServletRequest request) {
        RestServiceResult<Map> result = new RestServiceResult<Map>();
        //RestServiceResult<List<Map>> data = remoteBaseService.getLoginTimesByDept();
        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        //RestServiceResult<List<Map>> messData = remoteBaseService.getMessDatas();
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            //List<Map> listMap=messData.getData();
            //loseCreditService.initMessData(listMap);
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.mianBodyRate());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/increaseRateByMonth.json")
    public RestServiceResult<List<Map>> increaseRateByMonth(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.increaseRateByMonth());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/outRateByMonth.json")
    public RestServiceResult<List<Map>> outRateByMonth(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.outRateByMonth());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/frRegisterRangeTime.json")
    public RestServiceResult<List<Map>> frRegisterRangeTime(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.frRegisterRangeTime());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/frRegisterMoney.json")
    public RestServiceResult<List<Map>> frRegisterMoney(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.frRegisterMoney());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/frArea.json")
    public RestServiceResult<List<Map>> frArea(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.frArea());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/frIndustry.json")
    public RestServiceResult<List<Map>> frIndustry(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.frIndustry());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/frOperateeAnalyse.json")
    public RestServiceResult<List<Map>> frOperateeAnalyse(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.frOperateeAnalyse());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/zrrPopProperty.json")
    public RestServiceResult<List<Map>> zrrPopProperty(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.zrrPopProperty());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/zrrDegree.json")
    public RestServiceResult<List<Map>> zrrDegree(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.zrrDegree());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/zrrSex.json")
    public RestServiceResult<List<Map>> zrrSex(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.zrrSex());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/zrrJob.json")
    public RestServiceResult<List<Map>> zrrJob(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.zrrJob());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/zrrAge.json")
    public RestServiceResult<List<Map>> zrrAge(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.zrrAge());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
    
    /**
     * 异议修改分页列表
     * @param page
     * @return
     */
    @RequestMapping(value = "/zrrFeatureAnalyse.json")
    public RestServiceResult<List<Map>> zrrFeatureAnalyse(HttpServletRequest request) {
        RestServiceResult<List<Map>> result = new RestServiceResult<List<Map>>();

        RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(HttpServletHelper.getUserToken(request));
        //RestServiceResult<List<DictEntity>> codesData = remoteBaseService.getDictByDictKey("HCLX");
        
        SysUser userInfo = null;
        if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
            userInfo = user.getData();
            if (null == userInfo || userInfo.getId() <= 0) {
                result.setCode(RestServiceResult.CODE_UNKNOW);
                result.setMsg("系统异常，请稍后再试！");
                ExceptionLogger.error("bigScreenForBlackAndRedService#getList", "未获取到当前用户信息！");
                return result;
            }
            /*List<DictEntity> listCodes=codesData.getData();*/
            result.setData(loseCreditService.zrrFeatureAnalyse());
            return result;
        } else {
            result.setCode(user.getCode());
            result.setMsg(user.getMsg());
            return result;

        }
    }
   
}